<template>
    <layout>


    	<mt-header title="老师评语">
            <a href="/member/teacher" slot="left">
                <mt-button  icon="back"></mt-button>
            </a>
		</mt-header>
		<!--style="note"-->

    	<div class="box">
    		<div class="top" :style="note">
    			<div class="mark"></div>
    			<div class="top_img">
    				<img src="http://weidian-test.oss-cn-shenzhen.aliyuncs.com/edu/img/header_portrait2.png" />
    			</div>
    			<div class="top_name">{{ teacher.name }}</div>
    			<div class="top_time">入职时间：{{ teacher.createTime }}</div>
    		</div>

    		<div class="con">
    			<div class="title">老师简介:</div>
    			<div class="con_lr">{{ teacher.intro }}</div>
    		</div>

    		<div class="teach">

    			<label>老师评分:</label>
    			<input type="number" v-model="score" placeholder="请填写分数,满分为100" />
    		</div>

    		<div class="txte_box">
    			<textarea placeholder="请输入你老师的评语吧:" maxlength="200" @input="rest" v-model="content"></textarea>
    			<span>{{restNumber}}/200字</span>
    		</div>
    	</div>

    	<div class="footer">
    		<div @click="comment">匿名发布评语</div>
    	</div>
    </layout>
</template>
<style lang="scss">
    @import "index.scss";
</style>
<script type="text/babel">
    import { api } from 'framework/config.js';
    import Layout from "component/layout/standard";

    import Vue from 'vue'
    import Mint from 'mint-ui';
    Vue.use(Mint);

    export default {
        components: {
            Layout
        },
        data(){
            return {
                score: '',
                content: '',
                restNumber: 200,

				note: {
					backgroundImage: "url(" + require("../../../../asset/img/banner.png") + ")",
					backgroundRepeat: "no-repeat",
					backgroundSize: "100%  100%",

				}
            }
        },
        computed: {
            api(){
                return api();
            },
            rest(){
                var length = this.content.length;
                this.restNumber = 200 - length;
            }
        },
        methods: {
            comment(){
                let param = new URLSearchParams();
                param.append("type", 3);
                param.append("id", this.teacher.id);
                param.append("content", this.content);
                param.append("score", this.score)

                this.$http.post('/api/comment/information/add',
                    param
                ).then((response) => {
                    if (response.status == 200){
                        let data = response.data;
                        if (data.code == 200) {
                            this.content = '';
                            this.reload();
                        }
                    }else{
                    }
                })
            }

        },
        created(){
        },
        mounted() {


        }
    }
</script>

